/*
A script for Dynamic Zombie Sandbox. 
Involves a group of protagonists defending a town for a certain amount of time
They get a bunch of epic guns, but there are many, many zombies.

It is currently broken, being fixed for next release, hopefully
*/


if (player != player) then
{
    waitUntil {player == player};
    waitUntil {time > 10};
};


private ["_rad","_cnps","_towns","_townnumber","_pos","_trig","_epicGuns","_epicAmmo","_rnd","_weapon","_weapons","_mag"];

//=======================================================1
//=======================================================
sleep .1;


//=======================================================3
//=======================================================


if (CVG_debug == 2) then {
    player sidechat "Picking a town to battle in:";
};
if (isServer) then {
    _rad=10000;
    _cnps = getArray (configFile >> "CfgWorlds" >> worldName >> "centerPosition");
    _towns= nearestLocations [_cnps, ["CityCenter"], _rad];
    
    //=======================================================4
    
    //puts player in random town
    _townnumber = random floor (count _towns);
    battleLoc = _towns select _townnumber;
    publicVariable "battleLoc";
};
sleep 1;

player setpos (getpos battleLoc);

if (CVG_debug == 2) then {
    player sidechat format ["location chosen, %1",battleloc];
};
//puts player in random town

//=======================================================5
//=======================================================
// Time to make the battle:

//Sets the agrro radius and spawn density to an huge amount
CLY_maxaggroradius=800;
CLY_defaultdensity=50;

//=======================================================6
//Create the zombie spawner
if (isServer) then {
    [battleLoc] execVM "craigs_scripts\360Zspawn.sqf";
    //=======================================================7
    //=======================================================
    
    
    //insert timer here
    waitUntil {time > 240};
    
    [nil,nil,rHINT,"You escaped, you can live another day!"] call RE;
    [nil,nil,rSIDECHAT,"You escaped, you can live another day!"] call RE;
    sleep 3;
    [nil,nil,rENDMISSION,"END1"] call RE;
    endMission "END1";
    
};
//=======================================================8

//distance check goes here





